Skip to content

Conversation

@alexsch01
Copy link
Contributor

@alexsch01 alexsch01 commented Nov 10, 2025

This issue happens when a synchronous request is intercepted and the routeHandler argument to cy.intercept is given


The second part of this PR (prevent cross origin cookies from breaking sync requests)

  • prevents the browser from freezing when a sync request is made through the cross origin runner

Additional details

Steps to test

How has the user experience changed?

PR Tasks


Note

Detects synchronous XMLHttpRequest calls and avoids intercepting or applying cross-origin cookie automation, preventing browser hangs.

  • Bugfix: synchronous XHR handling
    • runner injection: mark sync XHR via x-cypress-is-sync-request in XMLHttpRequest.open; track _isSyncRequest and skip credentials signaling in send for sync requests.
    • proxy:
      • Request middleware: read/delete x-cypress-is-sync-request, set req.isSyncRequest.
      • Types: add req.isSyncRequest: boolean.
      • Response middleware: if req.isSyncRequest, skip cross-origin cookie automation; emit warnings.
    • net-stubbing: in InterceptedRequest.addDefaultSubscriptions, if req.isSyncRequest, warn and skip setting up cy.intercept() subscriptions (no interception).
    • Docs: changelog entry noting the freeze fix when intercepting synchronous requests with a routeHandler.

Written by Cursor Bugbot for commit 88c83e1. This will update automatically on new commits. Configure here.

@alexsch01 alexsch01 marked this pull request as draft November 10, 2025 15:06
@cypress-app-bot
Copy link
Collaborator

@alexsch01 alexsch01 marked this pull request as ready for review November 10, 2025 15:31
@mschile
Copy link
Contributor

mschile commented Nov 13, 2025

Hi @alexsch01 👋🏼, thanks for opening this PR! Just to make sure I understand the proposed changes, this would resolve the freezing issue but the routeHandler of the intercepted request would not be executed. Is my understanding correct?

@alexsch01
Copy link
Contributor Author

Hi @alexsch01 👋🏼, thanks for opening this PR! Just to make sure I understand the proposed changes, this would resolve the freezing issue but the routeHandler of the intercepted request would not be executed. Is my understanding correct?

The routeHandler is executed but the request that goes to the server won't be modified

req.headers["foo"] = "bar"

The server will not get this since it's not resolved, but anything you console.log in the routeHandler will print in DevTools console

@mschile
Copy link
Contributor

mschile commented Nov 14, 2025

Ok, I see the before:request event is still emitted but since this is a sync request, the event is received after the sync request has already been fully processed. I'm going to discuss this further with the team but my initial thought is that we should skip the adding the subscriptions entirely here.

@alexsch01
Copy link
Contributor Author

The second part of the fix (7b4f2e7) fixes a freezing issue when there's a sync request in cy.origin block

The downside is cross-origin cookies most likely won't work in this case

In cases where you must use cy.origin due to navigating to a different subdomain, this allows the test to work as expected when there's a sync request

@mschile
Copy link
Contributor

mschile commented Nov 14, 2025

Thanks for cross origin explanation. I'll have to look into it further.

@mschile
Copy link
Contributor

mschile commented Nov 18, 2025

@alexsch01, I discussed this PR with the rest of the team and we are good with proceeding. We should skip adding the subscriptions entirely here so the routeHandler won't get run. We would also like to log out some warnings to the terminal to inform the user that the sync request was not intercepted and for the cross-origin case that cookies may not have been applied.

@alexsch01
Copy link
Contributor Author

@mschile I skipped adding the subscriptions entirely for sync requests and added the 2 warnings

Let me know how that looks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Browser will freeze when sync request is intercepted

4 participants